package com.ruoyi.system.service.gallery.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.system.domain.supe.Substation;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.zhuangxiumapper.SubstationMapper;
import com.ruoyi.system.service.gallery.SubstationService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubstationServiceImpl implements SubstationService {


    @Autowired
    private SubstationMapper substationMapper;
    @Autowired
    private SysUserMapper sysUserMapper;


    /**
     * 查询分站
     *
     * @param substationId 分站ID
     * @return 分站
     */
    @Override
    public Substation selectSubstationById(Long substationId)
    {
        return substationMapper.selectSubstationById(substationId);
    }

    @Override
    public Substation findSubById(Long userId) {
        return substationMapper.findSubById(userId);
    }

    /**
     * 查询分站列表
     *
     * @param substation 分站
     * @return 分站
     */
    @Override
    public List<Substation> selectSubstationList(Substation substation)
    {
        return substationMapper.selectSubstationList(substation);
    }

    /**
     * 新增分站
     *
     * @param substation 分站
     * @return 结果
     */
    @Override
    public int insertSubstation(Substation substation)
    {
        return substationMapper.insertSubstation(substation);
    }

    /**
     * 修改分站
     *
     * @param substation 分站
     * @return 结果
     */
    @Override
    public int updateSubstation(Substation substation)
    {
        return substationMapper.updateSubstation(substation);
    }

    /**
     * 批量删除分站
     *
     * @param substationIds 需要删除的分站ID
     * @return 结果
     */
    @Override
    public int deleteSubstationByIds(Long[] substationIds)
    {
        return substationMapper.deleteSubstationByIds(substationIds);
    }

    /**
     * 删除分站信息
     *
     * @param substationId 分站ID
     * @return 结果
     */
    @Override
    public int deleteSubstationById(Long substationId)
    {
        return substationMapper.deleteSubstationById(substationId);
    }

    @Override
    public String checkUserIdUnique(Long userId) {
        int i = substationMapper.checkUserIdUnique(userId);
        if (i>0){
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
